package com.burstly.lib.component.networkcomponent.burstly.html.mraid;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import com.burstly.lib.component.networkcomponent.IActivityLifeCycleAware;
import com.burstly.lib.component.networkcomponent.burstly.OverlayContainer;
import com.burstly.lib.component.networkcomponent.burstly.html.CloseableContainer;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.ScreenOrientationManager;
import com.burstly.lib.util.UiSafeWebView;
import com.burstly.lib.util.Utils;

class MraidExpandedView<T extends MraidView,  extends IActivityLifeCycleAware> extends MraidOverlay<T>
  implements Runnable
{
  static final LoggerExt LOG = LoggerExt.getInstance();
  static final String TAG = OverlayContainer.class.getSimpleName();
  private ExpandAndOrientationProperties mExpandedProperties;
  private DisplayMetrics mMetrics;
  private Handler mUiHandler;

  MraidExpandedView(ViewGroup paramViewGroup, T paramT)
  {
    super(paramT, paramViewGroup);
    setApplyInOutAnimation(false);
    this.mUiHandler = new Handler();
    this.mMetrics = new DisplayMetrics();
    ((WindowManager)getContext().getSystemService("window")).getDefaultDisplay().getMetrics(this.mMetrics);
  }

  MraidExpandedView(T paramT)
  {
    this((ViewGroup)((Activity)paramT.getContext()).findViewById(16908290), paramT);
  }

  private FrameLayout.LayoutParams createLayoutParams(Integer paramInteger1, Integer paramInteger2)
  {
    int i;
    int j;
    if (isValidValue(paramInteger1, paramInteger2))
      if (exceedsMaxWidth(paramInteger1.intValue()))
      {
        i = Utils.getFillparentValue();
        if (!exceedsMaxHeight(paramInteger2.intValue()))
          break label73;
        j = Utils.getFillparentValue();
      }
    label40: for (FrameLayout.LayoutParams localLayoutParams = new FrameLayout.LayoutParams(i, j); ; localLayoutParams = new FrameLayout.LayoutParams(Utils.getFillparentValue(), Utils.getFillparentValue()))
    {
      localLayoutParams.gravity = 17;
      return localLayoutParams;
      i = (int)Utils.scale(paramInteger1.intValue());
      break;
      label73: j = (int)Utils.scale(paramInteger2.intValue());
      break label40;
    }
  }

  private boolean exceedsMaxHeight(int paramInt)
  {
    return (int)Utils.scale(paramInt) > getParentView().getMeasuredHeight();
  }

  private boolean exceedsMaxWidth(int paramInt)
  {
    return (int)Utils.scale(paramInt) > getParentView().getMeasuredWidth();
  }

  private static boolean isValidValue(Integer paramInteger1, Integer paramInteger2)
  {
    return (paramInteger2 != null) && (paramInteger1 != null) && (paramInteger2.intValue() > 0) && (paramInteger1.intValue() > 0);
  }

  protected CloseableContainer<?> addChildToLayout(ViewGroup paramViewGroup, T paramT)
  {
    CloseableContainer localCloseableContainer = super.addChildToLayout(paramViewGroup, paramT);
    if (!this.mExpandedProperties.getUseCustomClose().booleanValue());
    for (boolean bool = true; ; bool = false)
    {
      localCloseableContainer.setShowCloseIndicator(bool);
      localCloseableContainer.setShowCloseButtonDelay(paramT.getCloseButtonShowDelay());
      paramT.setLayoutParams(createLayoutParams(this.mExpandedProperties.getWidth(), this.mExpandedProperties.getHeight()));
      localCloseableContainer.requestFocus(130);
      return localCloseableContainer;
    }
  }

  protected ViewGroup createContainerLayout()
  {
    FrameLayout local1 = new FrameLayout(getContext())
    {
      public boolean dispatchKeyEvent(KeyEvent paramAnonymousKeyEvent)
      {
        switch (paramAnonymousKeyEvent.getKeyCode())
        {
        default:
          return super.dispatchKeyEvent(paramAnonymousKeyEvent);
        case 4:
        }
        ((MraidView)MraidExpandedView.this.getChildView()).close();
        super.dispatchKeyEvent(paramAnonymousKeyEvent);
        return true;
      }

      public boolean onTouchEvent(MotionEvent paramAnonymousMotionEvent)
      {
        super.onTouchEvent(paramAnonymousMotionEvent);
        return true;
      }
    };
    local1.setBackgroundColor(Color.argb(200, 255, 255, 255));
    return local1;
  }

  public void hideOverlayed()
  {
    ScreenOrientationManager localScreenOrientationManager = ((MraidView)getChildView()).getScreenOrientationMgr();
    if (localScreenOrientationManager != null)
    {
      localScreenOrientationManager.restoreDefaultOrientation();
      ((MraidView)getChildView()).setScreenOrientationMgr(null);
    }
    this.mUiHandler.removeCallbacks(this);
    super.hideOverlayed();
  }

  public void run()
  {
    if (!((MraidView)getChildView()).wasDestroyed())
      super.showOverlayed();
  }

  void setExpandedProperties(ExpandAndOrientationProperties paramExpandAndOrientationProperties)
  {
    this.mExpandedProperties = paramExpandAndOrientationProperties;
  }

  public void showOverlayed()
  {
    Utils.checkNotNull(this.mExpandedProperties, "Expanded properties must not be null");
    ScreenOrientationManager localScreenOrientationManager = new ScreenOrientationManager((Activity)((MraidView)getChildView()).getContext());
    ((MraidView)getChildView()).setScreenOrientationMgr(localScreenOrientationManager);
    localScreenOrientationManager.setOrientation(this.mExpandedProperties.getForceOrientation(), this.mExpandedProperties.getAllowOrientationChange().booleanValue());
    this.mUiHandler.postDelayed(this, 500L);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.mraid.MraidExpandedView
 * JD-Core Version:    0.6.2
 */